import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by lanouhn on 17/7/18.
 */
public class CatchImage1 {
    public static void main(String[] args) throws IOException {
        downLoad("http://down.52pk.com/uploads/170713/5000_101612_1.jpg","biaoqing.jpg");
    }

    public static void downLoad(String urlString, String filename) throws IOException {
        URL url = new URL(urlString);
        URLConnection con = url.openConnection();
        InputStream is = con.getInputStream();
        byte[] bs = new byte[1024];
        int len;
        OutputStream os = new FileOutputStream(filename);
        while((len = is.read(bs)) != -1){
            os.write(bs, 0, len);
        }
        os.close();
        is.close();
    }
}
